
void _CenterWindow(HWND hWnd, HWND hParent = NULL)
{
	assert(NULL != hWnd && IsWindow(hWnd));

	if (NULL == hParent || IsWindow(hParent))
	{
		hParent = GetDesktopWindow();
	}

	if (NULL != hWnd && IsWindow(hWnd))
	{
		RECT rtWnd;
		RECT rtParent;
		GetClientRect(hWnd, &rtWnd);
		GetClientRect(hParent, &rtParent);

		int nW	= rtWnd.right - rtWnd.left;
		int nH	= rtWnd.bottom - rtWnd.top;

		int nX	= ((rtParent.right - rtParent.left) - nW) >> 1;
		int nY	= ((rtParent.bottom - rtParent.top) - nH) >> 1;

		SetWindowPos(hWnd, NULL, nX, nY, nW, nH, SWP_NOACTIVATE);
	}

	return;
}